import { sourceUrl } from '@/config';
import { Image, Text, View } from '@tarojs/components';
import React from 'react';
import ProductTitle from '@/components/product/ProductTitle';

import './index.scss';

const ProductItem = ({ goodsList = [], onClick }) => {
  return (
    <View className="ShopProductClassification-ProductItem">
      {goodsList?.map((good, index) => (
        <View
          className="goodInfo"
          key={'theme' + good.id + '_' + index}
          onClick={() => {
            onClick(good);
          }}
        >
          <View className="goodIcon">
            <Image
              className="gIcon"
              src={good.url?.indexOf('http') === 0 ? good.url : sourceUrl + good.url}
            />
          </View>
          <View className="goodBase">
            <Text className="goodName omit-2">{good.title}</Text>
            {/* <ProductTitle product={good} /> */}
            <View className="var-flex">
              <Text className="goodPrice customePageStyle"><Text className='price-span'>¥</Text>{good.price}</Text>
              <Text className="goodSale">已售卖{good.saleNum || 0}件</Text>
            </View>
          </View>
        </View>
      ))}
    </View>
  );
};

export { ProductItem };
